﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Channels;
//using Albatross.WCF.Extenions.ServiceModel.Channels;


/*
 * Want more WCF tips?
 * Visit http://webservices20.blogspot.com/
 */


namespace Albatross.WCF.Extenions.Bindings
{
	public class ClearUsernameBinding : CustomBinding
	{
		public ClearUsernameBinding()
		{
			_ElementCollection = new BindingElementCollection();
		}
		private MessageVersion messageVersion = MessageVersion.None;

		public void SetMessageVersion( MessageVersion value )
		{
			this.messageVersion = value;
		}
		private BindingElementCollection _ElementCollection = null;
		public BindingElementCollection ClearElement
		{
			get
			{
				return _ElementCollection;
			}
		}
		public override BindingElementCollection CreateBindingElements()
		{
			if ( _ElementCollection.Count == 0 )
			{
				_ElementCollection.Add( new TextMessageEncodingBindingElement()
				{
					MessageVersion = this.messageVersion
				} );
				_ElementCollection.Add( SecurityBindingElement.CreateUserNameOverTransportBindingElement() );
				_ElementCollection.Add( new AutoSecuredHttpTransportElement() );
			}
			return _ElementCollection;
		}

		public override string Scheme
		{
			get
			{
				return "http";
			}
		}
	}
}
